/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tv.global.modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author ctrosch
 */
@Entity
@Table(name = "GRCCOH", schema = "dbo")
public class Concepto implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ConceptoPK id;
    @Basic(optional = false)
    @Column(name = "GRCCOH_DESCRP", nullable = false, length = 60)
    private String descrp;

    @JoinColumns({
        @JoinColumn(name = "GRCCOH_MODCPT", referencedColumnName = "GRTCPH_MODULO", nullable = false, insertable=false, updatable=false),
        @JoinColumn(name = "GRCCOH_TIPCPT", referencedColumnName = "GRTCPH_TIPCPT", nullable = false, insertable=false, updatable=false)
    })
    @ManyToOne(optional = false)
    private EstructuraDeConcepto estructuraDeConcepto;

    @Column(name = "GRCCOH_DEBAJA")
    private Character debaja;    
    @Column(name = "USR_GRCCOH_MDPREC", length = 10)
    private String mdprec;

    @OneToMany
    public List<ImpuestoPorConcepto> impuestos;

    public Concepto() {
    }

    public Concepto(ConceptoPK id) {
        this.id = id;
    }

    public Concepto(ConceptoPK id, String descrp) {
        this.id = id;
        this.descrp = descrp;
    }

    public Concepto(String grccohModcpt, char grccohTipcpt, String grccohCodcpt) {
        this.id = new ConceptoPK(grccohModcpt, grccohTipcpt, grccohCodcpt);
    }

    public ConceptoPK getId() {
        return id;
    }

    public void setId(ConceptoPK id) {
        this.id = id;
    }


    public Character getDebaja() {
        return debaja;
    }

    public void setDebaja(Character debaja) {
        this.debaja = debaja;
    }

    public String getDescrp() {
        return descrp;
    }

    public void setDescrp(String descrp) {
        this.descrp = descrp;
    }

    public String getMdprec() {
        return mdprec;
    }

    public void setMdprec(String mdprec) {
        this.mdprec = mdprec;
    }

    public EstructuraDeConcepto getEstructuraDeConcepto() {
        return estructuraDeConcepto;
    }

    public void setEstructuraDeConcepto(EstructuraDeConcepto estructuraDeConcepto) {
        this.estructuraDeConcepto = estructuraDeConcepto;
    }

    public List<ImpuestoPorConcepto> getImpuestos() {
        return impuestos;
    }

    public void setImpuestos(List<ImpuestoPorConcepto> impuestos) {
        this.impuestos = impuestos;
    }
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Concepto)) {
            return false;
        }
        Concepto other = (Concepto) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "tv.global.modelo.Concepto[id=" + id + "]";
    }

}
